<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2020/11/30
 * Time: 18:21
 */
require_once(dirname(__FILE__) . '/../../inc/config.inc.php');
require_once(dirname(__FILE__) . '/../../function.php');
IsModelPriv('member');


$page = isset($_GET['page']) ? intval($_GET['page']) : 0;
$size = isset($_GET['limit']) ? intval($_GET['limit']) : 0;
$dtime = isset($_GET['dtime']) ? htmlspecialchars($_GET['dtime']) : "";

$dtime=trim($dtime);
$manageid = isset($_GET['manageid']) ? intval($_GET['manageid']) : 0;   //用户的身份
$school = isset($_GET['school']) ? htmlspecialchars($_GET['school']) : 0;   //用户的身份
$mobile = isset($_GET['mobile']) ? htmlspecialchars($_GET['mobile']) : "";   //用户的身份
$start_num = ($page - 1) * $size;



$sql="SELECT *  FROM `#@__visit` where 1   ";

if ($mobile!="") {
    $sql .= "  and mobile  like '%$mobile%' ";
}
if ($school!="") {
    $sql .= "  and school  like '%$school%' ";
}


if ($manageid>0) {
    $sql .= "  and uid='$manageid'  ";
}

if ($dtime != "") {
    $time_arr = explode("~", $dtime);
    if (is_array($time_arr) && count($time_arr) == 2) {
        $start_time = strtotime(trim($time_arr[0]));
        $end_time = strtotime(trim($time_arr[1]))+ 3600 * 24 - 1;
        $sql .= " AND post_time>'$start_time' AND post_time<'$end_time' ";

    }

}



$dosql->Execute($sql,8);
$count=$dosql->GetTotalRow(8);
$sql.=" order by id desc  LIMIT $start_num, $size ";
$dosql->Execute($sql);
while ($row = $dosql->GetArray()) {


    $row['manage_name']=GetManageName($row['uid']);
    $row['addtime'] = GetDateTime($row['post_time']);
    $row_arr['data'][] = $row;
}
if (empty($row_arr['data'])) {
    $row_arr['data'][] = [];
}
$row_arr['code'] = 0;
$row_arr['msg'] = "success";
$row_arr['count'] = $count;
echo json_encode($row_arr);
